<template>
    <div id="repaTaskGen" v-loading="loading">
        <v-tableTitle :btnConfig="btnConfig"
                      :tableSelectData="tableSelectData"
                      :title="$t('out.unallot')"
                      @revocation="revocation"></v-tableTitle>
        <v-table
            :hasEdit="false"
            :pageSize="pageSize"
            :page="page"
            :tableConfig="tableConfig"
            :tableData="tableData"
            :total="total"
            @findData="getTableData"
            @getTableData="getTableData"
            @searhData="searhData"
            @selectData="selectData"
            @upData="getTableData"
            ref="table"
        ></v-table>
    </div>
</template>

<script type="text/ecmascript-6">
import tableTitle from "commons/TableTitle";
import table from "commons/Table";
import baseMixin from "@/mixins/BaseMixin";
import config from "./Config";

export default {
    name: "unallocateorder",
    mixins: [baseMixin, config],
    data() {
        return {
            loading: false,
            tableConfig: [
                {
                    label: this.$t('out.wavekey'),
                    prop: "wavekey",
                    input: "input",
                },
                {
                    label: this.$t('out.wavetype'),
                    prop: "wavetype",
                    input: "select",
                    options: this.getOptions("querycodeLkup/RTXWAVETYPE")
                },
                {
                    label: this.$t('out.orderkey'),
                    prop: "orderkey",
                    input: "input",
                },
                {
                    label: this.$t('in.podate1'),
                    prop: "orderdate",
                    input: "date",
                },
                {
                    label: this.$t('config.shipper'),
                    prop: "storerkey",
                    input: "input",
                },
                {
                    label: this.$t('bill.customer'),
                    prop: "c_company",
                    input: "input",
                },
                {
                    label: this.$t('config.deliveryAddress'),
                    prop: "consigneekey",
                    input: "input",
                },
                {
                    label: this.$t('config.carrier'),
                    prop: "carriername",
                    input: "input",
                },
                {
                    label: this.$t('out.unfinishqty'),
                    prop: "openqty",
                    input: "input",
                },
                {
                    label: this.$t('out.qtyunpicked'),
                    prop: "qtyunpicked",
                    input: "input",
                },
                {
                    label: this.$t('out.shippedqty'),
                    prop: "shippedqty",
                    input: "input",
                },
                {
                    label: this.$t('common.status'),
                    prop: "status",
                    input: "select",
                    options: this.getOptions("queryOrderStatusDropDown")
                },
                {
                    label: this.$t('out.rtxshippart'),
                    prop: "rtxshippart",
                    input: "select",
                    options: [
                        {code: 'Y', description: this.$t('code.yes')},
                        {code: 'N', description: this.$t('code.no')},
                    ]
                }
            ],
            tableData: [],
            pageSize: 10,
          page: 1,
            total: 0,
            tableSelectData: [],
            tableSearhData: {},
        };
    },
    computed: {
        btnConfig() {
            return [
                {label: this.$t('out.revocation1'),certigier: !this.btnPermNameList.includes('WM020701'), disabled: true, invalid: "revocation"},
            ]
        }
    },
    created() {
    },
    methods: {
        async revocation(data) {
            try {
                this.loading = true;
                let res = await this.$api.post(`/unAllocateOrder`, data);
                
                    this.$message.success(res.returnMgr);
                    let page = sessionStorage.getItem('page');
                    this.getTableData(page, this.tableSearhData);
                    
                
            } catch (e) {
                this.$message.error(e);
            }finally {
                this.loading =false;
            }
        },
        //选中的内容
        selectData(data) {
            this.tableSelectData = data;
        },
        async getTableData(page, data) {
            try {
                this.loading = true;
                let res = await this.$api.post(`/queryUnallocateOrderList/${page}`, data);
                
                    this.tableData = res.page.list;
                  this.page = res.page.curpage;
                    this.pageSize = res.page.pageSize;
                    this.total = res.page.total;
                
            } catch (e) {
                this.$message.error(e);
            } finally {
                this.loading = false;
            }
        },
        //搜索的值
        searhData(data, up) {
            if (!up) {
                this.tableSearhData = data;
            } else {
                this.tableSearhData = data;
                this.getTableData(1, this.tableSearhData);
            }
        },
    },
    mounted() {
        // ;
        this.$store.commit("setSkip", {});
        this.$store.commit("setNewFlag", false);
        this.$store.commit("setRouteData", {});
        this.getTableData(1, {});
    },
    watch: {},
    components: {
        "v-tableTitle": tableTitle,
        "v-table": table,
    }
};
</script>

<style scoped>
#repaTaskGen {
    width: 100%;
    height: 99%;
    padding-top: 6px;
}
</style>
